package com.sjsq.service.impl;

import com.sjsq.dao.CardDao;
import com.sjsq.dao.impl.CardDaoImpl;
import com.sjsq.po.Book;
import com.sjsq.po.Card;
import com.sjsq.po.User;
import com.sjsq.service.CardService;

import java.util.List;

/**
 * @author DHS
 * @date 2020/12/04 23:01
 */
public class CardServiceImpl implements CardService {

    private CardDao dao = new CardDaoImpl();

    @Override
    public List<Card> getCard(Integer id) {
        if(id != null){
            return dao.getCard(id);
        }
        return null;
    }

    /**
     * 添加信息到购物车
     * @param user
     * @param book
     * @param booknum
     * @return
     */
    @Override
    public boolean addCard(User user, Book book, Integer booknum) {
        return dao.addCard(user,book,booknum);
    }

    /**
     * 根据Book查询booknum
     * @param book
     * @return
     */
    @Override
    public Integer getBookNum(Book book) {
        if(dao.getBookNum(book) == null){
            return 0;
        }
        return dao.getBookNum(book);
    }
}
